#include<iostream>
#include<string>
#define MaxSize 50
using namespace std;
typedef struct{
	char data[MaxSize];
	int length;
} SqString;
void Getnextval(SqString* str,int nextval[]);
void StrAssign(SqString* &str,char s[]);
int KMP(SqString* str,SqString* t);
int main()
{
	SqString *str,*t;
	str=new SqString;
	t=new SqString;
	str->length=0;
	char s[MaxSize],st[MaxSize];
	int n,i;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>s;
		StrAssign(str,s);
		cin>>st;
		StrAssign(t,st);
		KMP(str,t);
	}
}
void StrAssign(SqString* &str,char s[])
{
	int i;
	for(i=0;s[i];i++){
		str->data[i]=s[i];
	}str->length=i;
}
void Getnextval(SqString* str,int nextval[])
{
	int j=0,k=-1;
	nextval[0]=-1;
	while(j<str->length){
		if(k==-1||str->data[j]!=str->data[k]){
			j++;k++;
			if(str->data[j]!=str->data[k])nextval[j]=k;
			else nextval[j]=nextval[k];
		}
		else {
			k=nextval[k];
		}
	}
}
int KMP(SqString* str,SqString* t)
{
	int nextval[MaxSize],i=0,j=0;
	Getnextval(str,nextval);
	while(i<str->length&&j<t->length){
		if(j==-1||str->data[i]==t->data[j]){
			i++;j++;
		}
		else {
			j=nextval[j];
		}
	}
	if(j>=t->length)
		cout<<(i-t->length)<<endl;
	else 
		cout<<"not find!"<<endl;
}
